home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat5 / r10k_evcntrs.z / r10k_evcntrs
Encoding:
Text File  |  2001-04-17  |  54.3 KB  |  1,190 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      r10k_evcntrs, r10k_event_counters, r10k_counters - Programming the
  10.      processor event counters
  11.  
  12. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  13.      The R10000 and R12000 processors include counters that can be used to
  14.      count the frequency of events during the execution of a program.  The
  15.      information returned by the counters can be helpful in optimizing the
  16.      program.  The ppppeeeerrrrffffeeeexxxx(1) and ssssssssrrrruuuunnnn(1) commands provide convenient
  17.      interfaces to hardware counter information.
  18.  
  19. TTTTHHHHEEEE CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS
  20.      The R10000 processor supplies two performance counters for counting
  21.      certain hardware events. Each counter can track one event at a time and
  22.      there are a choice of sixteen events per counter. There are also two
  23.      associated control registers which are used to specify which event the
  24.      relevant counter is counting.
  25.  
  26.      The R12000 processor supplies two performance counters for counting
  27.      hardware events. Each counter can track one event at a time, and you can
  28.      choose among 32 events per counter.
  29.  
  30.      Using performance counters in a machine with both R10000 and R12000
  31.      processors is currently undefined.
  32.  
  33.      Each counter is a 32-bit read / write register and is incremented by one
  34.      each time the event specified in its associated control register occurs.
  35.      Furthermore, the control registers allow one to indicate that the events
  36.      are only counted in a specific mode. The modes may be user mode or
  37.      several choices of kernel mode, or some combination of kernel and user
  38.      mode.
  39.  
  40.      The counters can optionally assert an interrupt upon overflow, which is
  41.      defined to be when the most significant bit of one of the counter
  42.      registers (bit 31) becomes set. If such an overflow interrupt is enabled
  43.      for that event in the associated control register, then the interrupt
  44.      will be presented to the cpu. Whether the interrupt is asserted or not
  45.      the counting of events will continue after overflow.
  46.  
  47. TTTTHHHHEEEE CCCCOOOONNNNTTTTRRRROOOOLLLL RRRREEEEGGGGIIIISSSSTTTTEEEERRRRSSSS
  48.      The format of the control registers is as follows:
  49.  
  50.  
  51.      31               8            4        3       2       1       0
  52.      ___________________________________________________________________
  53.        |        0     | Event   |   IE   |   U   |   S   |   K   | EXL |
  54.      ___________________________________________________________________
  55.  
  56.      Bit 4 is the interrupt enable bit, which specifies whether overflows for
  57.      the specified event will generate interrupts or not. Bits 3 through 0
  58.      specify either the mode the event is counted in or the count enable bits.
  59.      These bits will enable counting when they match the equivalent KSU
  60.      settings in the status register of the R10000 or R12000. That is:
  61.  
  62.  
  63.  
  64.                                                                         PPPPaaaaggggeeee 1111
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  72.  
  73.  
  74.  
  75.      U bit <----> KSU = 2, EXL = 0, ERL = 0 (user mode)
  76.  
  77.      S bit <----> KSU = 1, EXL = 0, ERL = 0 (supervisor mode, not supported)
  78.  
  79.      K bit <----> KSU = 0, EXL = 0, ERL = 0 (kernel mode)
  80.  
  81.      EXL bit <---> EXL = 1, ERL = 0 (transient kernel mode)
  82.  
  83.      ERL is a field in the status register on coprocessor 0.  It is set when
  84.      the processor hits an error and is forced into kernel mode.
  85.  
  86.      If the KSU bits in the status register are 2, and the ERL and EXL bits
  87.      are both off, events enabled with the U bit will be counted. In this way,
  88.      a program that intends to use the performance counters directly must
  89.      specify the events that are to be counted and the modes in which they are
  90.      to be counted.
  91.  
  92. EEEEVVVVEEEENNNNTTTTSSSS
  93.      The following events can be tracked by the performance counters on R10000
  94.      processors:
  95.  
  96.      0=cycles
  97.           Incremented on each clock cycle.
  98.  
  99.      1=issued instructions
  100.           Incremented each time an instruction is issued to ALU, FPU or
  101.           load/store units.
  102.  
  103.      2=issued loads
  104.           Incremented when a load, prefetch, or synchronization instruction is
  105.           issued.
  106.  
  107.      3=issued stores
  108.           Incremented when a store instruction is issued.
  109.  
  110.      4=issued store conditionals
  111.           Incremented when a conditional store instruction is issued.
  112.  
  113.      5=failed store conditionals
  114.           Incremented when a store-conditional instruction fails. A failed
  115.           store-conditional instruction will, in the normal course of events,
  116.           graduate; so this event represents a subset of the store conditional
  117.           instructions counted on event 20 (graduated store conditionals).
  118.  
  119.      6=Decoded branches
  120.           Incremented when a branch is decoded (for revision 2.x processors)
  121.           or resolved (for revision 3.x processors).
  122.  
  123.      7=Quadwords written back from secondary cache
  124.           Incremented when data is written back from secondary cache to the
  125.           system interface.
  126.  
  127.  
  128.  
  129.  
  130.                                                                         PPPPaaaaggggeeee 2222
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  138.  
  139.  
  140.  
  141.      8=correctable secondary cache data array ECC errors
  142.           Incremented when single-bit ECC erros are detected on data read from
  143.           secondary cache.
  144.  
  145.      9=primary instruction cache misses
  146.           Incremented when the next instruction is not in primary instruction
  147.           cache.
  148.  
  149.      10=secondary instruction cache misses
  150.           Incremented when the next instruction is not in secondary
  151.           instruction cache.
  152.  
  153.      11=instruction misprediction from secondary cache way prediction table
  154.           Incremented when the secondary cache way mispredicted an
  155.           instruction.
  156.  
  157.      12=external interventions
  158.           Incremented when an external intervention is entered into the Miss
  159.           Handling Table (MHT), provided that the intervention is not an
  160.           invalidate type.
  161.  
  162.      13=external invalidations
  163.           Incremented when an intervention is entered into the Miss Handling
  164.           Table, provided that the intervention is an invalidate type.
  165.  
  166.      14=virtual coherency conditions or ALU/FPU completion cycles
  167.           Incremented on virtual coherency conditions (on revision 2.x R10000
  168.           processors) or on ALU/FPU functional unit completions cycles (on
  169.           revision 3.x R10000 processors).
  170.  
  171.      15=graduated instructions
  172.           Incremented when an instruction is graduated.
  173.  
  174.      16=cycles
  175.           Incremented on each clock cycle.
  176.  
  177.      17=graduated instructions
  178.           Incremented when an instruction is graduated.
  179.  
  180.      18=graduated loads
  181.           Incremented on a graduated load, prefetch, or synchronization
  182.           instruction.
  183.  
  184.      19=graduated stores
  185.           Incremented on a graduated store instruction.
  186.  
  187.      20=graduated store conditionals
  188.           Incremented when a graduated conditional store instruction is
  189.           issued.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                                                         PPPPaaaaggggeeee 3333
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  204.  
  205.  
  206.  
  207.      21=graduated floating-point instructions
  208.           Incremented when a graduated floating-point instruction is issued.
  209.  
  210.      22=quadwords written back from primary data cache
  211.           Incremented when data is written back from primary data cache to
  212.           secondary cache.
  213.  
  214.      23=TLB misses
  215.           Incremented when a translation lookaside buffer (TLB) refill
  216.           exception occurs.
  217.  
  218.      24=mispredicted braches
  219.           Incremented when a branch is mispredicted.
  220.  
  221.      25=primary (L1) data cache misses.
  222.           Incremented when the next data item is not in primary data cache.
  223.  
  224.      26=secondary (L2) data cache misses.
  225.           Incremented when the next data item is not in secondary data cache.
  226.  
  227.      27=data mispredicted from secondary cache way prediction table
  228.           Incremented when the secondary cache way mispredicted a data item.
  229.  
  230.      28=external intervention hits in secondary cache (L2)
  231.           Set as follows when an external intervention is determined to have
  232.           hit in secondary cache:
  233.           00   Invalid, ho hit detected
  234.           01   Clean, shared
  235.           10   Clean, exclusive
  236.           11   dirty, exclusive
  237.  
  238.      29=external invalidation hits in secondary cache (L2)
  239.           Set when an external invalidate request is determined to have hit in
  240.           the secondary cache. Its value is equivalent to that described for
  241.           event 28.
  242.  
  243.      30=store/fetch exclusive to clean block in secondary cache (L2)
  244.           Incremented on each cycle by the number of entries in the Miss
  245.           Handling Table (MHT) waiting for a memory operation to complete.
  246.  
  247.      31=store/fetch exclusive to shared block in secondary cache (L2)
  248.           Incremented when an update request is issued for a line in the
  249.           secondary cache. If the line is in the clean state, the counter is
  250.           incremented by one. If the line is in the shared state, the counter
  251.           is incremented by two. The conditional counting mechanism can be
  252.           used to select whether one, both, or neither of these events is
  253.           chosen.
  254.  
  255.      Note that the definition of events 6 and 14 on counter 0 differ depending
  256.      on the R10000 chip revision.  The chip revision can be determined via the
  257.      command hhhhiiiinnnnvvvv(1).
  258.  
  259.  
  260.  
  261.  
  262.                                                                         PPPPaaaaggggeeee 4444
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  270.  
  271.  
  272.  
  273.      The following events can be tracked by the performance counters on R12000
  274.      processors:
  275.  
  276.      0=cycles
  277.           Incremented on each clock cycle.
  278.  
  279.      1=decoded instructions
  280.           Incremented by the total number of instructions decoded on the
  281.           previous cycle. Since decoded instructions may later be killed (for
  282.           a variety of reasons), this count reflects the overhead due to
  283.           incorrectly speculated branches and exception processing.
  284.  
  285.      2=decoded loads
  286.           Incremented when a load instruction was decoded on the previous
  287.           cycle. Prefetch, cache operations, and synchronization instructions
  288.           are not included in the count of decoded loads.
  289.  
  290.      3=decoded stores
  291.           Incremented if a store instruction was decoded on the previous
  292.           cycle. Store conditionals are included in this count.
  293.  
  294.      4=mishandling table occupancy
  295.           Incremented on each cycle by the number of currently valid entries
  296.           in the Miss Handling Table (MHT). The MHT has five entries.  Four
  297.           entries are used for internally generated accesses; the fifth entry
  298.           is reserved for externally generated events. All five entries are
  299.           included in this count. See event 8 for a related definition.
  300.  
  301.      5=failed store conditionals
  302.           Incremented when a store-conditional instruction fails. A failed
  303.           store-conditional instruction will, in the normal course of events,
  304.           graduate; so this event represents a subset of the store-conditional
  305.           instructions counted on event 20 (graduated store-conditionals).
  306.  
  307.      6=resolved conditional branches
  308.           Incremented both when a branch is determined to have been
  309.           mispredicted and when a branch is determined to have been correctly
  310.           predicted. When this determination of the accuracy of a branch-
  311.           prediction is known, the branch is known as "resolved." This counter
  312.           correctly reflects the case of multiple floating-point conditional
  313.           branches being resolved in a single cycle.
  314.  
  315.      7=Quadwords written back from secondary cache
  316.           Incremented on each cycle that the data for a quadword is written
  317.           back from secondary cache to the system interface unit.
  318.  
  319.      8=correctable secondary cache data array ECC errors
  320.           Incremented on the cycle following the correction of a single-bit
  321.           error in a quadword read from the secondary cache data array.
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                                                         PPPPaaaaggggeeee 5555
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  336.  
  337.  
  338.  
  339.      9=primary instruction cache misses
  340.           Incremented one cycle after an instruction fetch request is entered
  341.           into the Miss Handling Table.
  342.  
  343.      10=secondary instruction cache misses
  344.           Incremented the cycle after a refill request is sent to the system
  345.           interface module of the CPU. This is normally just after the L2 tags
  346.           are checked and a miss is detected, but it may be delayed if the
  347.           system interface module is busy with another request.
  348.  
  349.      11=instruction misprediction from secondary cache way prediction table
  350.           Incremented when the secondary cache control begins to retry an
  351.           access because it hit in the unpredicted way, provided the access
  352.           that initiated the access was an instruction fetch.
  353.  
  354.      12=external interventions
  355.           Incremented on the cycle after an intervention is entered into the
  356.           Miss Handling Table, provided that the intervention is not an
  357.           invalidated type.
  358.  
  359.      13=external invalidations
  360.           Incremented on the cycle after an intervention is entered into the
  361.           Miss Handling Table, provided that the intervention is an invalidate
  362.           type.
  363.  
  364.      14=ALU/FPU progress cycles
  365.           Incremented on the cycle after either ALU1, ALU2, FPU1, or FPU2
  366.           marks an instruction as done.
  367.  
  368.      15=graduated instructions
  369.           Incremented by the number of instructions that were graduated on the
  370.           previous cycle. Integer multiply and divide instructions each count
  371.           two graduated instructions because they occupy two entries in the
  372.           active list.
  373.  
  374.      16=executed prefetch instructions
  375.           Incremented on the cycle after a prefetch instruction does its tag-
  376.           check, regardless of whether a data cache line refill is initiated.
  377.  
  378.      17=prefetch primary data cache misses
  379.           Incremented on the cycle after a prefetch instruction does its tag-
  380.           check and a refill of the corresponding data cache line is
  381.           initiated.
  382.  
  383.      18=graduated loads
  384.           Incremented by the number of loads that graduated on the previous
  385.           cycle. Prefetch instructions are included in this count. Up to four
  386.           loads can graduate in one cycle.
  387.  
  388.      19=graduated stores
  389.           Incremented on the cycle after a store graduates. Only one store can
  390.           graduate per cycle. Store conditionals are included in this count.
  391.  
  392.  
  393.  
  394.                                                                         PPPPaaaaggggeeee 6666
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  402.  
  403.  
  404.  
  405.      20=graduated store conditions
  406.           Incremented on the cycle following the graduation of a store-
  407.           conditional instruction. Both failed and successful store-
  408.           conditional instructions are included in this count; so sucessful
  409.           store-conditionals can be determined as the difference between this
  410.           event and event 5 (failed store-conditionals).
  411.  
  412.      21=graduated floating-point instructions
  413.           Incremented by the number of floating-point instructions that
  414.           graduated on the previous cycle. There can be 0 to 4 such
  415.           instructions.
  416.  
  417.      22=quadwords written back from primary data cache
  418.           Incremented on each cycle that a quadword of data is valid and is
  419.           written from primary data cache to secondary cache.
  420.  
  421.      23=TLB misses
  422.           Incremented on the cycle after the translation lookaside buffer
  423.           (TLB) miss handler is invoked.
  424.  
  425.      24=mispredicted branches
  426.           Incremented on the cycle after a branch is _r_e_s_t_o_r_e_d because it was
  427.           mispredicted.
  428.  
  429.      25=primary data cache misses
  430.           Incremented one cycle after a request is entered into the SCTP
  431.           logic, provided that the request was initially targeted at the
  432.           primary data cache. Such requests fall into three categories:
  433.           1) Primary data cache misses.
  434.  
  435.           2) Requests to change the state of
  436.           secondary and primary data cache
  437.           lines from clean to dirty ("update"
  438.           requests) due to stores that hit
  439.           a clean line in the primary data
  440.           cache.
  441.  
  442.           3) Requests initiated by cache
  443.           operation instructions.
  444.  
  445.      26=secondary data cache misses
  446.           Incremented the cycle after a refill request is sent to the system
  447.           interface module of the CPU. This is normally just after the L2 tags
  448.           are checked and a miss is detected, but it can be delayed if the
  449.           system interface module is busy with another request.
  450.  
  451.      27=data misprediction from secondary cache way prediction table
  452.           Incremented when the secondary cache control begins to retry an
  453.           access because it hit in the unpredicted way. The counter is
  454.           incremented only if access that initiated the access was not an
  455.           instruction fetch.
  456.  
  457.  
  458.  
  459.  
  460.                                                                         PPPPaaaaggggeeee 7777
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  468.  
  469.  
  470.  
  471.      28=state of external intervention hits in secondary cache
  472.           Set on the cycle after an external intervention is determined to
  473.           have hit in the secondary cache. The value of the event is equal to
  474.           the state of the secondary cache line that was hit. Setting a
  475.           performance control register to select this event has a special
  476.           effect on the conditional counting behavior. If event 28 or 29 is
  477.           selected, the sense of the "Negated conditional counting" bit is
  478.           inverted. See the description of conditional counting for details.
  479.           The values are:
  480.           00   Invalid, ho hit detected
  481.           01   Clean, shared
  482.           10   Clean, exclusive
  483.           11   dirty, exclusive
  484.  
  485.      29=state of invalidation hits in secondary cache (L2)
  486.           Set on the cycle after an external invalidate request is determined
  487.           to have hit in secondary cache. Its value is equivalent to that
  488.           described for event 28.
  489.  
  490.      30=Miss Handling Table entries accessing memory
  491.           Incremented on each cycle by the number of entries in the Miss
  492.           Handling Table (MHT) waiting for a memory operation to complete. It
  493.           is always less than or equal to the value tracked by counter 4. An
  494.           entry is considered to begin accessing memory when the cache control
  495.           logic recognizes that a request must be sent via the SysA/D bus. An
  496.           entry is included in this count from that point until the entry is
  497.           removed from the MHT. For example, once the secondary cache tags are
  498.           checked and an secondary cache miss is recognized, the entry that
  499.           originated the request is included in this count. It continues to be
  500.           included until the last word of the refilled line is written into
  501.           the secondary cache and the MHT entry is removed. Unlike counter 4,
  502.           the fifth slot of the MHT, which is reserved for externally
  503.           generated requests, is not included in this count.
  504.  
  505.      31=store/prefetch exclusive to shared block in secondary cache (L2)
  506.           Incremented on the cycle after an update request is issued for a
  507.           line in the secondary cache. If the line is in the clean state, the
  508.           counter is incremented by one. If the line is in the shared state,
  509.           the counter is incremented by two. The conditional counting
  510.           mechanism can be used to select whether one, both, or neither of
  511.           these events is chosen.
  512.  
  513.      The kernel maintains 64-bit virtual counters for the user program using
  514.      the hardware counters. The view of the counters as being 64-bits is
  515.      maintained through the programming interfaces that use them, even though
  516.      the actual counters are only 32 bits. Similarly, there are only two
  517.      hardware counters per CPU, but the programming interface supports the
  518.      view that there are actually 32 counters. That is, a user program can
  519.      specify that more than one event per hardware counter is to be counted,
  520.      up to sixteen events per counter. The kernel will then multiplex the
  521.      events across clock tick boundaries. So, if a program is tracking more
  522.      than one event per counter, on every clock tick the kernel will check to
  523.  
  524.  
  525.  
  526.                                                                         PPPPaaaaggggeeee 8888
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  534.  
  535.  
  536.  
  537.      see if it is necessary to switch the events being tracked. If necessary,
  538.      it will save the counts for the previous events and set up the counters
  539.      for the next event. Thus, to the program there are 32 64-bit counters
  540.      available.
  541.  
  542.      The performance counters are available to the user program primarily
  543.      through the ppppeeeerrrrffffeeeexxxx(1) and ssssssssrrrruuuunnnn(1) commands.  You can also access the
  544.      counters through the ////pppprrrroooocccc(4) interface. A limited and more specialized
  545.      functionality is also provided through the ssssyyyyssssssssggggiiii(2) interface, but this
  546.      is not intended to be the general interface.
  547.  
  548.      Using ppppeeeerrrrffffeeeexxxx, you can select the events to be counted on hardware
  549.      counters and the executable program to be run.  The ppppeeeerrrrffffeeeexxxx command prints
  550.      the values of the hardware counters following the run.  See the ppppeeeerrrrffffeeeexxxx(1)
  551.      man page for more information.
  552.  
  553.      The ssssssssrrrruuuunnnn command is part of the SpeedShop performance analysis package,
  554.      and it provides input to the WorkShop ccccvvvvppppeeeerrrrffff(1) user interface or, in
  555.      ASCII format, to the pppprrrrooooffff(1) command.  See the various man pages, the
  556.      _S_p_e_e_d_S_h_o_p _U_s_e_r'_s _G_u_i_d_e, and the _D_e_v_e_l_o_p_e_r _M_a_g_i_c: _P_e_r_f_o_r_m_a_n_c_e _A_n_a_l_y_z_e_r
  557.      _U_s_e_r'_s _G_u_i_d_e for more information.
  558.  
  559.      Through ////pppprrrroooocccc, iiiiooooccccttttlllls allow you to start or stop using the counters, to
  560.      read the counts in your own counters, or to modify the way the counters
  561.      are being used. Since this interface specifies a process ID as a
  562.      parameter, it is possible, in general, for a process to read or
  563.      manipulate the counters of another process, as long as the process
  564.      belongs to the same process group or is root.
  565.  
  566.      There are also iiiiooooccccttttlllls that allow the program to specify overflow
  567.      thresholds on a per-event basis and to supply a signal to be sent to the
  568.      program upon overflow. That is, the fact that an interrupt can be
  569.      generated whenever a particular counter overflows can be exploited to
  570.      allow a program to specify a threshold _n for an event such that after _n
  571.      occurrences of the event an interrupt will be generated. In addition,
  572.      while the kernel is servicing the counter overflow interrupt, it can
  573.      perform some user-specified action, such as sending a user-specified
  574.      signal to the program whenever an overflow is generated or incrementing a
  575.      PC bucket for profiling. The latter choice is a more specialized
  576.      functionality and is not part of the general ////pppprrrroooocccc interface.
  577.  
  578.      For a process using the counters in user mode, the control block for the
  579.      counters is kept in the u-area. Thus, once the process forks, the child
  580.      acquires the same state of the counters as the parent, which implies that
  581.      the next time the child runs the performance counters will be run for the
  582.      child, tracking the same events as its parent. Therefore, the counter
  583.      values are zeroed for the child upon fork so that at a later time the
  584.      child's counters will accurately depict the activity of the child. For
  585.      this reason, it is possible for the parent to fork and then wait for the
  586.      child to exit. When the child exits, if the kernel sees that the parent
  587.      is waiting for the child it will add the child's 64-bit counters to those
  588.      of the parent, and the parent will thus have the event trace of the
  589.  
  590.  
  591.  
  592.                                                                         PPPPaaaaggggeeee 9999
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  600.  
  601.  
  602.  
  603.      child. Other methods for a parent to acquire a child's counters are
  604.      discussed with the PPPPIIIIOOOOCCCCSSSSAAAAVVVVEEEECCCCCCCCNNNNTTTTRRRRSSSS iiiiooooccccttttllll.
  605.  
  606.  
  607.  
  608. OOOOppppeeeerrrraaaattttiiiioooonnnn MMMMooooddddeeeessss ffffoooorrrr tttthhhheeee PPPPeeeerrrrffffoooorrrrmmmmaaaannnncccceeee CCCCoooouuuunnnntttteeeerrrrssss
  609.      There are two basic modes that the counters are used in, user mode and
  610.      system mode. Using them in user mode allows the counters to be shared
  611.      among any number of user programs. In this mode the kernel saves and
  612.      restores the counts and state of the counters across context switch
  613.      boundaries. System mode is defined when a user with root privileges uses
  614.      the counters in kernel mode (user mode and/or EXL mode may also be
  615.      specified, but kernel mode is essential). In this mode there are no
  616.      context switch boundaries and so other programs will not be able to use
  617.      the counters when they are in use in system mode.
  618.  
  619.      Therefore, when the counters are already in use in user mode, a program
  620.      which attempts to use them in system mode will fail with EBUSY since the
  621.      two modes cannot co-exist (unless certain commands are employed to force
  622.      releasing of the counters in user mode and the acquiring of them in
  623.      system mode- to be discussed later). Likewise, if the counters are in use
  624.      in system mode, any program attempting to use the counters will fail with
  625.      EBUSY (root-level or otherwise).
  626.  
  627.      The approach taken to these two operating modes is that system mode has a
  628.      higher priority. For this reason there is a syssgi command to forcibly
  629.      acquire the counters in system mode. Any current users of the counters on
  630.      any cpu will be forced to release them. And any users of the counters who
  631.      are not currently running will not be able to acquire them when they run
  632.      again. This latter situation holds at all times. That is, there may be
  633.      several programs sharing the counters in user mode. If at any moment they
  634.      happen to all be switched out, the counters are temporarily free. At this
  635.      point it is possible for a super-user to acquire the counters in system
  636.      mode. Then, when the other programs are run again, they won't be able to
  637.      acquire the counters since they are in use in system mode. Since this
  638.      program will then be run at this point without the intended event
  639.      counting, the kernel will arrange it such that this program will not use
  640.      the counters again, unless they are explicitly restarted. This is because
  641.      the values in the counters are no longer representative of the program.
  642.  
  643.      To re-iterate, a root-level program may receive EBUSY from the kernel if
  644.      it tries to acquire the counters in system mode through /proc and they
  645.      are actively in use at the time of the system call. If they are in use in
  646.      user mode by other programs but those programs are not running at the
  647.      time of the system call, then the counters will be successfully acquired
  648.      in system mode and the other programs will not be able to acquire them
  649.      again- the kernel will not try to start up the counters for those other
  650.      programs again.
  651.  
  652.      In order to make this situation visible to the program, a _g_e_n_e_r_a_t_i_o_n
  653.      number is employed to reflect the current state of the counters. In this
  654.      case, whenever the kernel does turn off the use of the counters for a
  655.  
  656.  
  657.  
  658.                                                                        PPPPaaaaggggeeee 11110000
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  666.  
  667.  
  668.  
  669.      program because the mode of operation has switched from user mode to
  670.      system mode, the _g_e_n_e_r_a_t_i_o_n number for the counters for the user programs
  671.      will be increased. Thus, subsequent reads of the counters will return the
  672.      new number and should signal the program that the counter values are not
  673.      to be trusted. The number will be discussed in greater detail later.
  674.  
  675.      To support using the counters in system mode, each cpu has its own
  676.      control block for the counters, pointed to in its private area. There is
  677.      also a global counter control block which maintains counter state for the
  678.      entire system. When the counters are being used in system mode they are
  679.      not read and stored across context switch boundaries. In fact, unless
  680.      they are explicitly read by a program, the counters are not read by the
  681.      kernel until there is an overflow interrupt. When this occurs the cpu on
  682.      which the interrupt occurs updates its own private virtual counters, no
  683.      changes are made to the global counter control block.
  684.  
  685.      When the counters are read in system mode via PIOCGETEVCTRS through
  686.      /proc, the per-cpu counters are all added together into the global
  687.      counters so that the global counters represent the sum total of the
  688.      counted events for the entire system. This same coalescing of the per-cpu
  689.      counters happens when the counters are released. Note that it is also
  690.      possible to read a particular cpu's counters via the syssgi
  691.      HWPERF_GET_CPUCNTRS command.
  692.  
  693.  
  694.                  /proc Commands for the Performance Counters
  695.  
  696.  
  697.      To support the /proc interface for the counters, there are several data
  698.      structures defined in /usr/include/sys/hwperftypes.h that are used to
  699.      either pass parameters with the calls or to receive data back from the
  700.      kernel.
  701.  
  702.  
  703.      struct hwperf_ctrlreg {
  704.              ushort_t     hwp_ev  :11, /* event counted */
  705.                           hwp_ie  :1,  /* overflow intr enable */
  706.                           hwp_mode:4;  /* user/kernel/EXL */
  707.      };
  708.  
  709.      typedef union {
  710.              short                 hwperf_spec;
  711.              struct hwperf_ctrlreg hwperf_creg;
  712.      } hwperf_ctrl_t;
  713.  
  714.      typedef struct {
  715.              hwperf_ctrl_t hwp_evctrl[HWPERF_EVENTMAX];
  716.      } hwperf_eventctrl_t;
  717.  
  718.      Each event is described to the kernel through an hwperf_ctrl_t. Where
  719.      relevant, the iiiiooooccccttttlllls take the address of an hwperf_eventctrl_t, the array
  720.      of 32 hwperf_ctrl_t's. If the user is not interested in an event, then
  721.  
  722.  
  723.  
  724.                                                                        PPPPaaaaggggeeee 11111111
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  732.  
  733.  
  734.  
  735.      care must be taken to ensure that the corresponding element in this array
  736.      is zero.
  737.  
  738.      For a user to gain access to the counters, it must indicate which events
  739.      are of interest and how they are to be counted; whether overflow
  740.      thresholds are to be used to generate overflow interrupts or not, and
  741.      what those thresholds are per event; and what signal the user program
  742.      would like to receive from the kernel upon overflow interrupt. All of
  743.      this information is conveyed with the structure hwperf_profevctrarg_t:
  744.  
  745.  
  746.      typedef struct hwperf_profevctrarg {
  747.           hwperf_eventctrl_t hwp_evctrargs;
  748.           int                hwp_ovflw_freq[HWPERF_EVENTMAX];
  749.           int                hwp_ovflw_sig; /* SIGUSR1,2 */
  750.      } hwperf_profevctrarg_t;
  751.  
  752.      With the above structure as parameter the user program must take care to
  753.      zero the hwp_ovflw_freq elements for which no overflow thresholds are
  754.      intended. The hwp_ovflw_sig field is used to tell the kernel which signal
  755.      the program wants to receive upon overflow interrupt. The acceptable
  756.      signals are between 1 and 32 (SIG32). This field should be zero if no
  757.      signals are wanted.
  758.  
  759.      The following structure is an array of 32 64-bit virtual counters and is
  760.      used when a program wants to read the virtual counters of a process:
  761.  
  762.      typedef struct {
  763.           __uint64_t hwp_evctr[HWPERF_EVENTMAX];
  764.      } hwperf_cntr_t;
  765.  
  766.      It is also possible to read the counters and all of the prusage
  767.      information of a process in one call. To this end the hwperf_prusage_t is
  768.      defined:
  769.  
  770.      typedef struct hwperf_prusage {
  771.           timespec_t pu_tstamp;  /* time stamp */
  772.           timespec_t pu_starttime; /* time process was started */
  773.           timespec_t pu_utime;   /* user CPU time */
  774.           timespec_t pu_stime;   /* system CPU time */
  775.           __uint64_t pu_minf;     /* minor (mapping) page faults */
  776.           __uint64_t pu_majf;     /* major (disk) page faults */
  777.           __uint64_t pu_utlb;     /* user TLB misses */
  778.           __uint64_t pu_nswap;    /* swaps (process only) */
  779.           __uint64_t pu_gbread;   /* gigabytes ... */
  780.           __uint64_t pu_bread;    /* and bytes read */
  781.           __uint64_t pu_gbwrit;   /* gigabytes ... */
  782.           __uint64_t pu_bwrit;    /* and bytes written */
  783.           __uint64_t pu_sigs;     /* signals received */
  784.           __uint64_t pu_vctx;     /* voluntary context switches */
  785.  
  786.  
  787.  
  788.  
  789.  
  790.                                                                        PPPPaaaaggggeeee 11112222
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  798.  
  799.  
  800.  
  801.           __uint64_t pu_ictx;     /* involuntary context switches */
  802.           __uint64_t pu_sysc;     /* system calls */
  803.           __uint64_t pu_syscr;    /* read() system calls */
  804.           __uint64_t pu_syscw;    /* write() system calls */
  805.           __uint64_t pu_syscps;   /* poll() or select() system calls */
  806.           __uint64_t pu_sysci;    /* ioctl() system calls */
  807.           __uint64_t pu_graphfifo;    /* graphics pipeline stalls */
  808.           __uint64_t pu_graph_req[8]; /* graphics resource requests */
  809.           __uint64_t pu_graph_wait[8];/* graphics resource waits */
  810.           __uint64_t pu_size;     /* size of swappable image in pages */
  811.           __uint64_t pu_rss;      /* resident set size */
  812.           __uint64_t pu_inblock;  /* block input operations */
  813.           __uint64_t pu_oublock;  /* block output operations */
  814.           __uint64_t pu_vfault;   /* total number of vfaults */
  815.           __uint64_t pu_ktlb;     /* kernel TLB misses */
  816.           cpu_mon_t pu_cpu_mon;   /* cpu monitoring stats */
  817.      } hwperf_prusage_t;
  818.  
  819.  
  820.  
  821.      The iiiiooooccccttttlllls available through /proc are the following:
  822.  
  823.  
  824.      _PPPP_IIII_OOOO_CCCC_EEEE_NNNN_EEEE_VVVV_CCCC_TTTT_RRRR_SSSS   - Start using the counters for a process, either in user
  825.                       mode or system mode. It initializes the counters for the
  826.                       target process and, if the process is running, starts
  827.                       them. Otherwise, the counters will be started the next
  828.                       time the process is run. Fails with EINVAL if events are
  829.                       specified events improperly, or if an input overflow
  830.                       frequency (threshold) is negative.
  831.  
  832.                       If supervisor or kernel mode is specified for any of
  833.                       the events and the caller does not have root privileges,
  834.                       it will fail with EPERM. EBUSY may be returned for two
  835.                       possible reasons:
  836.                       (1) the counters are already in use in system mode or,
  837.                       (2) the caller is requesting the counters in system
  838.                       mode and, at the time of the request, the counters are
  839.                       in use in user mode, on at least one cpu (this command
  840.                       will not forcibly acquire the counters for a root
  841.                       process).
  842.  
  843.                       Returns a positive generation number if successful.
  844.  
  845.      _PPPP_IIII_OOOO_CCCC_GGGG_EEEE_TTTT_EEEE_VVVV_CCCC_TTTT_RRRR_SSSS  - Read the virtual counters of the target process.
  846.                       The address of an hwperf_cntr_t must be supplied in
  847.                       the call.
  848.  
  849.                       Returns a positive generation number if successful.
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.                                                                        PPPPaaaaggggeeee 11113333
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  864.  
  865.  
  866.  
  867.      _PPPP_IIII_OOOO_CCCC_GGGG_EEEE_TTTT_PPPP_RRRR_EEEE_VVVV_CCCC_TTTT_RRRR_SSSS- Read a process's counters in addition to reading all
  868.                       the prusage information associated with the process.
  869.                       The address of an hwperf_prusage_t must be supplied
  870.                       with the call.
  871.  
  872.                       Returns a positive generation number if successful.
  873.  
  874.      _PPPP_IIII_OOOO_CCCC_GGGG_EEEE_TTTT_EEEE_VVVV_CCCC_TTTT_RRRR_LLLL  - Retrieve the control information for the process's
  875.                       counters: which events are being counted and the mode
  876.                       they are being counted in. The kernel will copyout an
  877.                       array of 32 event specifiers, so the user must supply
  878.                       an address of an hwperf_eventctrl_t.
  879.  
  880.                       Returns a positive generation number if successful.
  881.  
  882.      _PPPP_IIII_OOOO_CCCC_SSSS_EEEE_TTTT_EEEE_VVVV_CCCC_TTTT_RRRR_LLLL  - Modify how a program is using the counters, whether it
  883.                       be events and/or their associated mode of operation, or
  884.                       overflow threshold values, or overflow signal. Once the
  885.                       counters have been acquired this is how their operation
  886.                       for a program is modified without releasing the
  887.                       counters. Each time the PIOCSETEVCTRL is made the
  888.                       generation number for the target process's counters will
  889.                       be incremented. The parameter to this call is the
  890.                       address of an hwperf_profevctrarg_t.
  891.  
  892.                       Returns a positive generation number if successful.
  893.  
  894.      _PPPP_IIII_OOOO_CCCC_RRRR_EEEE_LLLL_EEEE_VVVV_CCCC_TTTT_RRRR_SSSS  - Release the performance counters- the target process
  895.                       will not have any events counted after this call. Note
  896.                       that the virtual counters associated with the target
  897.                       may still be read as long as the process has not exited.
  898.                       No parameters are necessary.
  899.  
  900.      _PPPP_IIII_OOOO_CCCC_SSSS_AAAA_VVVV_EEEE_CCCC_CCCC_NNNN_TTTT_RRRR_SSSS - Allow a parent process to receive the counter values
  901.                       of one of its children when it exits, without having to
  902.                       wait for the child (when the parent is waiting no
  903.                       explicit call is necessary). When the child exits its
  904.                       counter values will be added to the parent's, whether
  905.                       the parent is using its counters or not. No parameters
  906.                       are necessary other than target pid.
  907.  
  908.  
  909. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  910.      An example of how these commands would be used is given here. Suppose
  911.      that we wanted to count instruction cache misses and data cache misses
  912.      for our own program. That means that we want to count event 9 for both
  913.      counters, and these events would be counted in user mode.  The following
  914.      code would accomplish this. Note that the constants used are defined in
  915.      /usr/include/sys/hwperfmacros.h, and evctr_args is an
  916.      hwperf_profevctrarg_t.
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                                                                        PPPPaaaaggggeeee 11114444
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  930.  
  931.  
  932.  
  933.      pid = getpid();
  934.      sprintf(pfile, "/proc/%05d", pid);
  935.      fd = open(pfile, O_RDWR);
  936.      for (i = 0; i < HWPERF_CNTEVENTMAX; i++) {
  937.          if (i == 9) {
  938.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_mode = HWPERF_CNTEN_U;
  939.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_ie = 1;
  940.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_ev = i;
  941.              evctr_args.hwp_ovflw_freq[i] = 0;
  942.          } else {
  943.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_spec = 0;
  944.              evctr_args.hwp_ovflw_freq[i] = 0;
  945.          }
  946.      }
  947.  
  948.      for (i = HWPERF_CNT1BASE; i < HWPERF_EVENTMAX; i++) {
  949.          if (i == 9) {
  950.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_mode = HWPERF_CNTEN_U;
  951.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_ie = 1;
  952.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_creg.hwp_ev = i - HWPERF_CNT1BASE;
  953.              evctr_args.hwp_ovflw_freq[i] = 0;
  954.          } else {
  955.              evctr_args.hwp_evctrargs.hwp_evctrl[i].hwperf_spec = 0;
  956.              evctr_args.hwp_ovflw_freq[i] = 0;
  957.          }
  958.      }
  959.      evctr_args.hwp_ovflw_sig = 0;
  960.      generation1 = ioctl(fd, PIOCENEVCTRS, (void *)&evctr_args);
  961.      if (generation1 < 0) {
  962.          perror("failed to acquire counters");
  963.          exit errno;
  964.      }
  965.  
  966.  
  967.          . . . . . (body of program) . . . .
  968.  
  969.  
  970.      /* now read the counter values */
  971.      if ((generation2 = ioctl(fd, PIOCGETEVCTRS, (void *)&cnts)) < 0) {
  972.          perror("PIOCGETEVCTRS returns error");
  973.          exit(errno);
  974.      }
  975.  
  976.      /* generation number should be the same */
  977.      if (generation1 != generation2) {
  978.          printf("program lost event counters0);
  979.          exit 0;
  980.      }
  981.  
  982.      /* release the counters */
  983.  
  984.  
  985.  
  986.  
  987.  
  988.                                                                        PPPPaaaaggggeeee 11115555
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  996.  
  997.  
  998.  
  999.      if ((ioctl(fd, PIOCRELEVCTRS)) < 0) {
  1000.          perror("prioctl PIOCRELEVCTRS returns error");
  1001.          exit(errno);
  1002.      }
  1003.  
  1004.      /* print out the counts */
  1005.      printf("instruction cache misses: %d/0, cnts.hwp_evctr[9]);
  1006.      printf("data cache misses: %d/0, cnts.hwp_evctr[25]);
  1007.      exit 0;
  1008.  
  1009.  
  1010.                  Syssgi Commands for the Performance Counters
  1011.  
  1012.      The syssgi commands that access the event counters are not intended for
  1013.      general use. Rather, specialized commands are implemented through this
  1014.      interface. Note that all the commands are the first argument to the
  1015.      syssgi command SGI_EVENTCTR. The available commands are:
  1016.  
  1017.  
  1018.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______PPPP_RRRR_OOOO_FFFF_EEEE_NNNN_AAAA_BBBB_LLLL_EEEE     - Enable sprofil-like profiling using the
  1019.                              performance counters rather than the clock.
  1020.                              Returns EINVAL on incorrect input, or EBUSY
  1021.                              if the counters are already in use in system
  1022.                              mode. The second argument to this command is
  1023.                              the address of an hwperf_profevctrarg_t, the
  1024.                              argument is a profp, the fourth is the profcnt,
  1025.                              both referring to input necessary for profiling.
  1026.  
  1027.                              Returns a positive generation number if
  1028.                              successful.
  1029.  
  1030.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______EEEE_NNNN_SSSS_YYYY_SSSS_CCCC_NNNN_TTTT_RRRR_SSSS     - Forcibly acquire the counters in system mode.
  1031.  
  1032.                              ROOT PERMISSIONS ARE REQUIRED FOR THIS COMMAND.
  1033.  
  1034.                              Note that the counters must be set up in kernel
  1035.                              mode (usr and EXL may be included, but kernel mode
  1036.                              is required), EINVAL will be returned otherwise.
  1037.                              That is, at least one of the events must be
  1038.                              counted in kernel mode. Will fail with EBUSY if
  1039.                              the counters are already in use in system mode.
  1040.                              Otherwise, the command is guaranteed to return
  1041.                              the counters in system mode. Starts up the
  1042.                              counters on all the cpus, with all the cpus
  1043.                              counting the same events.
  1044.  
  1045.                              Takes as input (third parameter of syssgi call)
  1046.                              the address of an hwperf_profevctrarg_t, which
  1047.                              is set up just as it is for the PIOCENEVENTCTRS
  1048.                              (see example above).
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.                                                                        PPPPaaaaggggeeee 11116666
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  1062.  
  1063.  
  1064.  
  1065.  
  1066.                              Returns a positive generation number if
  1067.                              successful.
  1068.  
  1069.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______GGGG_EEEE_TTTT______SSSS_YYYY_SSSS_CCCC_NNNN_TTTT_RRRR_SSSS   - Read the global system counters to get the global
  1070.                              event counts. All of the per-cpu counters will be
  1071.                              aggregated into the global counters and the
  1072.                              results will be returned to the caller. Caller
  1073.                              must supply in third argument the address of
  1074.                              an hwperf_cntr_t.
  1075.  
  1076.                              Returns a positive generation number if
  1077.                              successful.
  1078.  
  1079.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______GGGG_EEEE_TTTT______CCCC_PPPP_UUUU_CCCC_NNNN_TTTT_RRRR_SSSS   - Read a particular cpu's event counters. The third
  1080.                              parameter is a cpuid, the fourth is the address
  1081.                              of an hwperf_cntr_t.
  1082.  
  1083.                              Returns a positive generation number if
  1084.                              successful, 0 otherwise (which would indicate
  1085.                              an invalid cpuid.)
  1086.  
  1087.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______GGGG_EEEE_TTTT______SSSS_YYYY_SSSS_EEEE_VVVV_CCCC_TTTT_RRRR_LLLL  - Retrieve the control information for the systems
  1088.                              event counters: which events are being counted
  1089.                              and the modes they are being counted in. The third
  1090.                              parameter must be the address of an
  1091.                              hwperf_eventctrl_t. Returns EINVAL if the counters
  1092.                              are not in use.
  1093.  
  1094.                              Returns a positive generation number if
  1095.                              successful.
  1096.  
  1097.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______SSSS_EEEE_TTTT______SSSS_YYYY_SSSS_EEEE_VVVV_CCCC_TTTT_RRRR_LLLL  - Modify how the system counters are operating,
  1098.                              whether it be events being counted and/or their
  1099.                              associated mode of operation, or overflow
  1100.                              threshold values, or overflow signal.
  1101.  
  1102.                              MUST BE ROOT TO ISSUE THIS COMMAND, or else EPERM
  1103.                              will be returned.
  1104.  
  1105.                              Once the counters have been acquired this is how
  1106.                              their operation is modified without releasing
  1107.                              them. Each time the system call
  1108.                              syssgi(SGI_EVENTCTR, HWPERF_SET_SYSEVCTRL,...)
  1109.                              is issued the generation number for the system's
  1110.                              counters is incremented. The third parameter to
  1111.                              this call is the address of an
  1112.                              hwperf_profevctrarg_t.
  1113.  
  1114.                              Returns a positive generation number if
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.                                                                        PPPPaaaaggggeeee 11117777
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127. PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))                                              PPPPEEEERRRRFFFF____CCCCOOOOUUUUNNNNTTTTEEEERRRRSSSS((((5555))))
  1128.  
  1129.  
  1130.  
  1131.                              successful.
  1132.  
  1133.      _HHHH_WWWW_PPPP_EEEE_RRRR_FFFF______RRRR_EEEE_LLLL_SSSS_YYYY_SSSS_CCCC_NNNN_TTTT_RRRR_SSSS    - Stop using the counters in system mode and to
  1134.                              make the counters available again.
  1135.                              ROOT PERMISSION REQUIRED.
  1136.  
  1137.                              Returns 0 upon success.
  1138.  
  1139.  
  1140. NNNNOOOOTTTTEEEESSSS
  1141.      The following list, ordered by events traced, details revision 3 of the
  1142.      R10000 CPU counters that return information different from the R12000 CPU
  1143.      counters.  If an event is not listed here, it is the same on both CPU
  1144.      types.
  1145.  
  1146.      Event               R10000                         R12000
  1147.      1       Issued instructions              Decoded instructions
  1148.      2       Issued loads                     Decoded loads
  1149.      3       Issued stores                    Decoded stores
  1150.      4       Issued store conditionals        Decoded store conditionals
  1151.      16      Cycles
  1152.      17      Graduated instructions           Data cache misses
  1153.      30      Store/fetch exclusive to clean   MHT entries
  1154.  
  1155. FFFFIIIILLLLEEEESSSS
  1156.      ////uuuussssrrrr////iiiinnnncccclllluuuuddddeeee////ssssyyyyssss////hhhhwwwwppppeeeerrrrffffttttyyyyppppeeeessss....hhhh
  1157.      ////uuuussssrrrr////iiiinnnncccclllluuuuddddeeee////ssssyyyyssss////hhhhwwwwppppeeeerrrrffffmmmmaaaaccccrrrroooossss....hhhh
  1158.  
  1159. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1160.      eeeeccccaaaaddddmmmmiiiinnnn(1M), eeeeccccssssttttaaaattttssss(1M), ppppeeeerrrrffffeeeexxxx(1M), lllliiiibbbbppppeeeerrrrffffeeeexxxx(3C), and lllliiiibbbbppppeeeerrrrffffeeeexxxx(3F).
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                                                                        PPPPaaaaggggeeee 11118888
  1187.  
  1188.  
  1189.  
  1190.